﻿using Data;
using Microsoft.Practices.Unity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Service.Impl
{
    public abstract class ManagerBase<T> : IManagerBase<T>
        where T : class
    {
        [Dependency]
        public IGenericRepository Repos { protected get; set; }

        public virtual void Add(T item)
        {
            Repos.Save<T>(item);
        }

        public virtual void Update(T item)
        {
            Repos.Save<T>(item);
        }

        public virtual void Delete(T item)
        {
            Repos.Delete<T>(item);
        }

        public virtual T Get(int id)
        {
            return Repos.GetById<T>(id);
        }

        public virtual IQueryable<T> Query()
        {
            return Repos.GetQueryable<T>();
        }
    }
}
